<?php
isset($_SERVER['SERVER_NAME']) ? $add = $_SERVER['SERVER_NAME'] : $add = "";
$_cfg = array(
    /*ws url配置*/
    "wsurl" => 'ws://' . 'lyp256.cn' . ':9999',
    "db_dbms" => 'mysql',
    "db_host" => 'lyp256.cn',
    "db_name" => 'chat',
    "db_user" => 'root',
    "db_pwd" => 'Qaz123456',
    /*session状态*/
    "session" => true

);

/*创建数据库实例*/
$sql_dsn = "{$_cfg['db_dbms']}:host={$_cfg['db_host']};dbname={$_cfg['db_name']}";
try {
    $_db = new PDO($sql_dsn, $_cfg['db_user'], $_cfg['db_pwd']);
    $_db->exec("set names utf8");
} catch (exception $e) {
    echo '<script>alert(\'连接数据库失败,请与管理员联系!\');</script>';
//    var_dump($e);
}
if ($_cfg['session']) {
    session_start();
}